
#include <C8051f330.H>                 // SFR declarations
#include <stdio.h>

//-----------------------------------------------------------------------------
// 16-bit SFR Definitions for 'F33x
//-----------------------------------------------------------------------------
sfr16 TMR2RL   = 0xca;                 // Timer2 reload value
sfr16 TMR2     = 0xcc;                 // Timer2 counter

/*
#define  ILEN  8                      			// size of serial receiving buffer       
unsigned char  istart;                			// receiving buffer start index          
unsigned char  iend;                  			// receiving buffer end index            
idata    char  inbuf[ILEN];           			// storage for receiving buffer          
idata    char  BufOfInt[ILEN];
idata    char  BufOfSMBCN[ILEN];
idata    char  BufOfSMBDAT[ILEN];
*/
unsigned int IntCounter;
unsigned char uSMB0CN;
unsigned char uSMB0DAT;
//bit bIntGeneral;

//#include <ws_iic_port.h>
#include <ws_iic.h>

extern bit SMBus_BUSY;

/*
void fnInitTimer2_2us (void)
{
   TMR2CN = 0x00;                      		// STOP Timer2; Clear TF2H and TF2L;
                                       		// disable low-byte interrupt; disable
                                       		// split mode; select internal timebase
   CKCON |= 0x10;                      		// Timer2 uses SYSCLK as its timebase

   TMR2RL  = -49;                  		// Init reload values	lei added 24.5*2=49
   TMR2    = TMR2RL;                   		// Init Timer2 with reload value
   ET2 = 0;                            	// disable Timer2 interrupts
//   TR2 = 1;                            		// start Timer2
}
*/
/*
void fnDelay2Xus(unsigned int nDelayTime)
{
   unsigned int count;

   TF2H = 0;                           // Clear Timer2 overflow flag
   TR2 = 1;                            // Start Timer2
   for (count = nDelayTime; count != 0; count--) {
      while (!TF2H);                   // wait for overflow
      TF2H = 0;                        // clear overflow indicator
   }
   TR2 = 0;                            // Stop Timer2
}

void Delay1s(void)
{
	unsigned int i;

	for(i=1000;i!=0;i--)
			fnDelay2Xus(500);
}
*/
/*
void main(void)
{
	unsigned char i,j;
	unsigned char uTemp;

	IntCounter = 0;

	PCA0MD &= ~0x40;                    	// WDTE = 0 (clear watchdog timer enable)
	SYSCLK_Init();
	PORT_Init();
	UART0_Init();
	SMBus_Init();
	Timer3_Init();
	fnInitTimer2_2us();
	Enb_Interrupt();

	printf("SMBus test Ver1.17\n");

	SMBus_BUSY = 0;

	for(i=0;i<8;i++)
	{
		fnAtmel24C02_ByteWrite(0xA0,i+0x40,0x40+i);	
		Delay1s();
	}	

	for(i=0;i<16;i++)
	{
		printf("%02bx-",i*16);
		for(j=0;j<16;j++)
		{
			uTemp=fnAtmel24C02_RandomRead(i*16+j);
			printf("%02bx ",uTemp);
		}
		printf("\n");
	}

	while(1);
}
*/